package com.ruoyi.web.admin.controller.system;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysAed;
import com.ruoyi.system.service.ISysAedService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiImplicitParam;

/**
 * AED信息Controller
 * 
 * @author ruoyi
 */
@Api(tags = "AED管理")
@RestController
@RequestMapping("/system/aed")
public class SysAedController extends BaseController
{
    private final ISysAedService sysAedService;

    public SysAedController(ISysAedService sysAedService) {
        this.sysAedService = sysAedService;
    }

    /**
     * 查询AED信息列表
     */
    @ApiOperation(value = "获取AED列表", notes = "获取所有AED信息")
    @PreAuthorize("@ss.hasPermi('system:aed:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysAed sysAed)
    {
        startPage();
        List<SysAed> list = sysAedService.selectSysAedList(sysAed);
        return getDataTable(list);
    }

    /**
     * 导出AED信息列表
     */
    @ApiOperation(value = "导出AED信息", notes = "导出所有AED信息数据")
    @PreAuthorize("@ss.hasPermi('system:aed:export')")
    @Log(title = "AED信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SysAed sysAed)
    {
        List<SysAed> list = sysAedService.selectSysAedList(sysAed);
        ExcelUtil<SysAed> util = new ExcelUtil<>(SysAed.class);
        return util.exportExcel(list, "AED信息数据");
    }

    /**
     * 获取AED信息详细信息
     */
    @ApiOperation(value = "获取AED详细信息", notes = "根据id获取AED详细信息")
    @ApiImplicitParam(name = "id", value = "AED ID", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
    @PreAuthorize("@ss.hasPermi('system:aed:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysAedService.selectSysAedById(id));
    }

    /**
     * 新增AED信息
     */
    @ApiOperation(value = "新增AED", notes = "新增AED信息")
    @PreAuthorize("@ss.hasPermi('system:aed:add')")
    @Log(title = "AED信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@Validated @RequestBody SysAed sysAed)
    {
        return toAjax(sysAedService.insertSysAed(sysAed));
    }

    /**
     * 修改AED信息
     */
    @ApiOperation(value = "修改AED", notes = "修改AED信息")
    @PreAuthorize("@ss.hasPermi('system:aed:edit')")
    @Log(title = "AED信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@Validated @RequestBody SysAed sysAed)
    {
        return toAjax(sysAedService.updateSysAed(sysAed));
    }

    /**
     * 删除AED信息
     */
    @ApiOperation(value = "批量删除AED", notes = "批量删除AED信息")
    @ApiImplicitParam(name = "ids", value = "AED ID数组", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long[].class)
    @PreAuthorize("@ss.hasPermi('system:aed:remove')")
    @Log(title = "AED信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysAedService.deleteSysAedByIds(ids));
    }
}